<?php
/**
 * Created by PhpStorm.
 * User: tangmusen
 * Date: 2017/9/1
 * Time: 10:06
 */

namespace app\admin\model;

use traits\model\SoftDelete;

class Members extends Base
{
    use SoftDelete;
    protected $deleteTime = 'delete_at';
    protected $table      = 'dl_member';
    protected $autoWriteTimestamp = true;

    /**
     * 根据用户名获取id
     */
    public function get_mobile_id($mobile){
        $result = $this->where(array('mobile'=>$mobile))->value('id');
        return $result;
    }
    /**
     * 登陆插入数据
     */
    public function register_add($v_data){
        $data['nickname']   = $v_data['nickname'];
        $data['mobile']     = $v_data['mobile'];
        $data['password']   = data_md5_key($v_data['password']);
        $data['create_at']  = time();
        $data['ip']         = request()->ip();
        $data['token']      = md5(rand(1111,9999));
        $result             = $this->allowField(true)->save($data);
        return $result;
    }
}